# Created with PyCharm.
# Project_Name SoftwareTesting2022
# PATH Needing
# Files_Name 图片上传.py
# Coding UTF-8
# @Version Python 3.8

# @author GeekChunky
# @Email caiyoupeng00@outlook.com

# @Date 2021/11/29
# @CreatTime 14:42

'''
Documentation comments:

'''

# Now Write Down Your Python Code in Editor...
# Wish You Happy Everyday !
from time import sleep

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

# 打驱动
driver = webdriver.Edge(r'C:\Users\caiyo\AppData\Local\Programs\Python\Python38\BroswerDriver\msedgedriver.exe')
# 最大化窗口
driver.maximize_window()
# get系统
driver.get('http://192.168.1.251')
# 输入账号
driver.find_element(By.XPATH, '//*[@id="loginName"]').send_keys('softtest2018')
# 输入密码
driver.find_element(By.XPATH, '//*[@id="pwd"]').send_keys('aaa')
# 点击登录
driver.find_element(By.XPATH, '//*[@id="fmedit"]/div/div[5]/input').click()
# 点击菜单栏 ——》 文档和资源管理
driver.find_element(By.XPATH, '//*[@id="tabmenu_docres"]/a').click()
# 点击新增
driver.find_element(By.XPATH, '/html/body/div[2]/div[3]/div[2]/div/input').click()
# 输入文档或资源名称
driver.find_element(By.XPATH, '//*[@id="res_title"]').send_keys('123456789')
# 选择器选择 ——》 资产管理系统软件(B/S和安卓)
Select(driver.find_element(By.XPATH, '//*[@id="softId_child"]')).select_by_visible_text('资产管理系统软件(B/S和安卓)')
# 选择状态 ——》 不发布
driver.find_element(By.XPATH, '//*[@id="fmedit"]/table/tbody/tr[3]/td[2]/input[2]').click()
# 上传文件
driver.find_element(By.XPATH, '//*[@id="dg"]/span[2]/input').send_keys(r'C:\Users\caiyo\OneDrive\软件测试\暑期培训计划.xlsx')
# 定义iframe
element = driver.find_element(By.XPATH, '//*[@id="cke_1_contents"]/iframe')
# 跳转框架
driver.switch_to.frame(element)
# 输入备注信息
driver.find_element(By.XPATH, '/html/body').send_keys('test')
# 返回主页面
driver.switch_to_default_content()
# 提交
driver.find_element(By.XPATH, '//*[@id="fmedit"]/div/div[1]').click()
# 等待2s
sleep(2)
# 弹出窗口确定
driver.find_element(By.XPATH, '//*[@id="cboxLoadedContent"]/div/div/div[2]/div[2]/div').click()
# 刷新
driver.refresh()
# 退出系统
driver.find_element(By.XPATH, '/html/body/div[1]/div/a[2]').click()
# 退出浏览器
driver.quit()
